package com.example.demo.enums;

import com.zhucan.enums.core.enums.CodeEnum;
import com.zhucan.enums.conversion.annotation.EnumAutoConverter;
import com.zhucan.enums.scanner.annotation.EnumScan;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 支付方式枚举
 * 
 * 演示不同的支付方式及其特性
 */
@Getter
@AllArgsConstructor
@EnumScan(
    description = "支付方式",
    defaultEnumCode = 1,
    category = "Payment"
)
@EnumAutoConverter
public enum PaymentMethodEnum implements CodeEnum {
    
    /**
     * 支付宝
     */
    ALIPAY(1, "支付宝"),
    
    /**
     * 微信支付
     */
    WECHAT_PAY(2, "微信支付"),
    
    /**
     * 银行卡
     */
    BANK_CARD(3, "银行卡"),
    
    /**
     * 信用卡
     */
    CREDIT_CARD(4, "信用卡"),
    
    /**
     * 余额支付
     */
    BALANCE(5, "余额支付"),
    
    /**
     * 货到付款
     */
    COD(6, "货到付款");

    private final Integer code;
    private final String name;

    @Override
    public Integer code() {
        return this.code;
    }

    @Override
    public String value() {
        return this.name;
    }
    
    /**
     * 是否为在线支付
     */
    public boolean isOnlinePayment() {
        return this != COD;
    }
    
    /**
     * 是否需要第三方
     */
    public boolean requiresThirdParty() {
        return this == ALIPAY || this == WECHAT_PAY;
    }
}
